﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace PersonJSONService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "PersonJsonService" in code, svc and config file together.
    public class PersonJsonService : IPersonJsonService
    {
        
         Person[] IPersonJsonService.GetPeople()
         {
             return PeopleRepository.People.ToArray();
         }

         Person[] IPersonJsonService.SavePerson(string name, string lastname, string age)
         {
             PeopleRepository.People.Add(new Person { firstName = name, lastName = lastname, age = Convert.ToInt16(age) });
             return PeopleRepository.People.ToArray();
         }
    }

    public static class PeopleRepository
    {
        public static List<Person> People = new List<Person>()
            {
                new Person{firstName = "Roman", lastName = "Law", age = 42},
                new Person{firstName = "Anta", lastName = "Mui", age = 46},
                new Person{firstName = "Leselie", lastName = "Cheung", age = 38}
            };
    }
}
